interface MessageImplements {
	info(title: string): void;
	wraning(title: string): void;
	success(title: string): void;
	error(title: string): void;
}

export function useMessage() {
	class MessageClass implements MessageImplements {
		// 普通提示
		info(title: string): void {
			uni.showToast({
        title: title,
        icon: 'none',
        duration: 1500,
        mask: false
      });
		}

		// 警告提示
    // TODO: 这里的提示未完成
		wraning(title: string): void {
			uni.showToast({
			  title: title,
			  icon: 'none',
			  duration: 1500,
			  mask: false
			});
		}

		// 成功提示
		success(title: string): void {
			uni.showToast({
			  title: title,
			  icon: 'success',
			  duration: 1500,
			  mask: false
			});
		}

		// 错误提示
		error(title: string): void {
			uni.showToast({
			  title: title,
			  icon: 'error',
			  duration: 1500,
			  mask: false
			});
		}
	}

	return new MessageClass();
}

export function useMessageBox() {
	class MessageBoxClass implements MessageImplements {
		// 普通提示
		info(msg: string,title: string='系统提示！'): void {
			uni.showModal({
        title: title,
        content: msg,
        showCancel: false
      })
		}

		// 警告提示
		wraning(msg: string, title:string='系统警告！'): void {
			uni.showModal({
			  title: title,
			  content: msg,
			  showCancel: false
			})
		}

		// 成功提示
		success(msg: string, title:string='成功提示！'): void {
			uni.showModal({
			  title: title,
			  content: msg,
			  showCancel: false
			})
		}

		// 错误提示
		error(msg: string, title:string='错误提示！'): void {
			uni.showModal({
			  title: title,
			  content: msg,
			  showCancel: false
			})
		}

		// 确认窗体
		confirm(msg: string, title:string='确认提示！') {
			return uni.showModal({
			  title: title,
			  content: msg,
			  showCancel: true
			})
		}
		// 提交内容
		prompt(msg: string, title:string='提交！') {
			return uni.showModal({
			  title: title,
			  content: msg,
			  showCancel: true,
        editable: true,
        placeholderText: '请输入内容！'
			})
		}
	}

	return new MessageBoxClass();
}
